define([],function(){
    var tpl = {};
    /*
     * OSI;
     * */
    tpl.questionsOsi = function(){
        var html = '';
        html += singleElectionOsi();
        html += blankOsi();
        html += blankList();
        html += single();
        html += blank();
        html += list();
        html += blankSingle();
        html += linkage();
        html += questionsOsi();
        return html;
    };
    var questionsOsi = function(){
        return '<script type="text/html" id="questionsOsi-tpl">'+
                    '<div class="panel-heading" id="{{id}}" group= "{{group}}">{{title}}</div>'+
                    '<div class="panel-body p-0-5">'+
                        '<ul class="ques-list">'+
                        '{{each questions as ques,i}}'+
                            '<li class="clearfix">'+
                                '<div>'+
                                    '{{if ques.type == "single" || ques.type == "checkbox"}}'+
                                    '{{include "singleElectionOsi2-tpl" ques}}'+
                                    '{{else if ques.type == "blank" }}'+
                                    '{{include "blankOsi2-tpl" ques}}'+
                                    '{{else if ques.type == "blankList"}}'+
                                    '{{include "blankList2-tpl" ques}}'+
                                    '{{else if ques.type == "linkage"}}'+
                                    '{{include "linkage2-tpl" ques}}'+
                                    '{{/if}}'+
                                '</div>'+
                                '<div class="ques-mark" fuId="{{ques.id}}" bak = "{{ques.bak}}">查看备注</div>'+
                            '</li>'+
                        '{{/each}}'+
                        '</ul>'+
                        '<div class="page">'+
                            '<span class="total">共&nbsp;{{length}}&nbsp;题</span>'+
                            '<div class="pull-right">'+
                                '<div class="btn-group" role="group"  id="btn-group">'+
                                '</div>'+
                            '</div>'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    /* 问卷题型 */
    /*
    * 联动：
     */
    var linkage = function(){
        return '<script type="text/html" id="linkage2-tpl">'+
                    '{{each list as li,i}}'+
                        '{{if li.type == "single" || li.type == "checkbox"}}'+
                            '{{include "single2-tpl" li}}'+
                        '{{else if li.type == "blank"}}'+
                            '{{include "blank2-tpl" li}}'+
                        '{{else if li.type == "blankList"}}'+
                            '{{include "list2-tpl" li}}'+
                        '{{else if li.type == "blankSingle"}}'+
                            '{{include "blankSingle2-tpl" li}}'+
                        '{{/if}}'+
                    '{{/each}}'+
            '</script>'
    };
    var blank = function(){
        return '<script type="text/html" id="blank2-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}} {{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques" >'+
                            '{{each description as val,i}}'+
                                '{{if val.item == "text" || val.item == "number" || val.item == "time" || val.item == "date" }}'+
                                   '<span class="underline">{{value}}</span>'+
                                '{{else}}'+
                                    '{{val.item}}'+
                                '{{/if}}'+
                            '{{/each}}'+
                            '<span >{{bak}}</span>'+
                        '</div>'+
                    '</div>'+
            '</script>'
    };
    var list = function(){
        return '<script type="text/html" id="list2-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques">'+
                            '{{each description as val,i}}'+
                                '{{if val.item == "text" || val.item == "number" || val.item == "time" || val.item == "date" }}'+
                                    '<span></span>'+
                                '{{else}}'+
                                    '{{val.item}}'+
                                '{{/if}}'+
                            '{{/each}}'+
                        '</div>'+
                        '<div class="blankList">'+
                            '{{if value}}'+
                                '{{each value as val,i}}'+
                                '<p>{{i+1}}.{{val.val}}</p>'+
                                '{{/each}}'+
                            '{{/if}}'+
                        '</div>'+
                    '</div>'+
            '</script>'
    };
    var single = function(){
        return '<script type="text/html" id="single2-tpl">'+
                    '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                        '<div class="ques">'+
                            '<span class = "ques_num">{{description}}</span> {{value}}'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    var blankSingle = function(){
        return '<script type="text/html" id="blankSingle2-tpl">'+
                '<div id="{{id}}" type="{{type}}" {{if !value}}{{if css == "none"}}style="display:none"{{/if}}{{/if}}>'+
                    '<div class="ques">'+
                        '{{each description as val,i}}'+
                            '{{if val.item == "text" || val.item == "number" || val.item == "time" || val.item == "date" }}'+
                                '<span class="underline">{{value}}</span>'+
                            '{{else}}'+
                                '{{val.item}}'+
                            '{{/if}}'+
                        '{{/each}}'+
                        '{{bak}}'+
                        '{{if values}}'+
                        '；&nbsp;{{values}}；{{optionVal}}'+
                        '{{/if}}'+
                    '</div>'+
                '</div>'+
                '</script>'
    }
    //填空：
    var blankOsi = function(){
        return '<script type="text/html" id="blankOsi2-tpl">'+
                    '<div class="ques" id="{{id}}" type="{{type}}">'+
                        '{{each description as val,i}}'+
                            '{{if val.item == "text" || val.item == "number" || val.item == "time" || val.item == "date" }}'+
                                '<span class="underline">{{value}}</span>'+
                            '{{else}}'+
                                '{{val.item}}'+
                            '{{/if}}'+
                        '{{/each}}'+
                    '</div>'+
            '</script>'
    };
    var blankList = function(){
        return '<script type="text/html" id="blankList2-tpl">'+
                        '<div class="ques" id="{{id}}" type="{{type}}" >'+
                            '{{each description as val,i}}'+
                                '{{if val.item == "text" || val.item == "number" || val.item == "time" || val.item == "date" }}'+
                                    '<span></span>'+
                                '{{else}}'+
                                    '{{val.item}}'+
                                '{{/if}}'+
                            '{{/each}}'+
                        '</div>'+
                        '<div class="blankList">'+
                            '{{if value}}'+
                                '{{each value as val,i}}'+
                                    '<p>{{i+1}}.{{val.val}}</p>'+
                                '{{/each}}'+
                            '{{/if}}'+
                        '</div>'+
            '</script>'
    };
    //osi单选：
    var singleElectionOsi = function(){
        return '<script type="text/html" id="singleElectionOsi2-tpl">'+
                            '<div class="ques" id="{{id}}" type="{{type}}">'+
                                '<span class = "ques_num">{{description}}</span> {{value}}'+
                            '</div>'+
                '</script>'
    };
    return tpl;
});